package com.ohc.leetcode.数组;

public class 最大连续1的个数No2 {
    public static int findMaxConsecutiveOnes(int[] nums) {
        int n = 0;
        int m = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                n++;
            } else {
                m = Math.max(m, n);
                n = 0;
            }

        }
        return Math.max(m, n);
    }

    public static void main(String[] args) {
        int[] nums = {1, 1, 0, 0, 1, 1};
        int maxConsecutiveOnes = findMaxConsecutiveOnes(nums);
        System.out.println("maxConsecutiveOnes = " + maxConsecutiveOnes);
    }
}
